package org.student.action;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;
import org.student.entity.SysUser;
import org.student.impl.HibernateDaoImpl;
import org.student.service.IUserInfoService;

@SuppressWarnings("all")
@Component("LoginAction")
public class LoginAction extends SuperAction{
	
	private SysUser user ; 
	private String forwardURL ;
	private IUserInfoService userInfoService ;
	private List<SysUser> userList ;
	
	public String login() throws Exception {
		try {
			this.userInfoService.checkUser(this.user.getUserName(), this.user.getPassword()) ;
		} catch (Exception e) {
			super.logFailureString("测试模块", "查询", "登陆测试", e) ;
			e.printStackTrace();
		}
		super.logSuccessString("测试模块", "查询", "登陆测试") ;
		this.forwardURL = "/index.jsp" ;
		return super.SUCCESS ; 
	}
	
	public String getAllUser() throws Exception {
		try {
			this.userList = this.userInfoService.getAllUser(super.getPageInfo()) ;
		} catch (Exception e) {
			super.logFailureString("测试模块", "查询", "登陆测试", e) ;
			e.printStackTrace();
		}
		super.logSuccessString("测试模块", "查询", "登陆测试") ;
		this.forwardURL = "/index.jsp" ;
		return "success";
	}

	public SysUser getUser() {
		return user;
	}

	public void setUser(SysUser user) {
		this.user = user;
	}

	public String getForwardURL() {
		return forwardURL;
	}

	public void setForwardURL(String forwardURL) {
		this.forwardURL = forwardURL;
	}
	
	public IUserInfoService getUserInfoService() {
		return userInfoService;
	}
	
	@Resource(name = "userInfoService")
	public void setUserInfoService(IUserInfoService userInfoService) {
		this.userInfoService = userInfoService;
	}

	public List<SysUser> getUserList() {
		return userList;
	}

	public void setUserList(List<SysUser> userList) {
		this.userList = userList;
	}
	
}
